<#-- @ftlvariable name="table" type="com.baomidou.mybatisplus.generator.config.po.TableInfo" -->
package ${package.Controller}.view;

import ${package.Entity}.${entity};
import com.bidanet.bdcms.core.vo.Page;
import com.bidanet.springmvc.demo.jkbuilder.data.JkNameValueDataImpl;
import com.bidanet.springmvc.demo.jkbuilder.data.JkUploadFile;
import kotlinx.html.*;
import kotlinx.html.stream.createHTML;
import vip.xuejike.ktpl.PageJkKtView;
import vip.xuejike.ktpl.libs.*;

/**
 *  Created by xuemingyu 2018/5/28
 */
class ${entity}View(var page: Page<${entity}>, private var ${entity?uncap_first}: ${entity}? = null) : PageJkKtView() {
    override fun content(): String {
        return createHTML().div {
            this.attributes["style"]="height:800px;width:1698px"
            jkForm(method = FormMethod.get) {
                jkFormItem {
                    <#list table.fields as field>
                        jkInput("${field.comment!'空字符串'}", formItem = false, inline = true, bind = ${entity?uncap_first}!!::${field.propertyName})
                    </#list>
                    jkButton("搜索")
                    jkButton("清空", type = JkButtonType.reset.name)
                    jkButton("新增", type = JkButtonType.dialog, url = "<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>/add")
                }
            }
            var i = 1
            jkTable(
                    linkedMapOf(
                            "序号" to JkTableCol {
                                text(i)
                                i++
                            },
                            <#list table.fields as field>
                                "${field.comment!'空字符串'}" to JkTableCol(${entity}::${field.propertyName}),
                            </#list>
                            "操作" to JkTableCol(width = "150px") {
                                jkButton("编辑", type = JkButtonType.dialog.name,
                                        url = "<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>/edit?id=${'$'}{it.id}",
                                        option = mapOf("title" to "编辑"))
                                jkButton(title = "删除", url = "<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>/del?id=${'$'}{it.id}", type = JkButtonType.confirm, option = "确认删除？") {
                                    val btn = this as BUTTON
                                    btn.classes += "layui-btn-danger"
                                }
                            }
                    ), dataList = page.list)
            jkPage(page.pageCurrent, count = page.total!!.toInt(), limit = page.pageSize)
        }
    }
}

class ${entity}EditView(var vo: ${entity}) : PageJkKtView() {
    override fun content(): String {
        return createHTML().div {
            jkForm(action = "./edit_save") {
                jkInput(formItem = false, bind = vo::id, type = InputType.hidden)
                <#list table.fields as field>
                       jkInput(title = "${field.comment!'空字符串'}", bind = vo::${field.propertyName})
                </#list>
                jkFormTitle {
                    jkButton(title = "保存", type = JkButtonType.ajax_submit.name) {
                    }
                }
            }
        }
    }
}

class ${entity}AddView(var vo: ${entity}) : PageJkKtView() {
    override fun content(): String {
        return createHTML().div {
            jkForm(action = "./add_save") {
                <#list table.fields as field>
                       jkInput(title = "${field.comment!'空字符串'}", bind = vo::${field.propertyName})
                </#list>
                jkFormTitle {
                    jkButton(title = "保存", type = JkButtonType.ajax_submit.name) {
                    }
                }
            }
        }
    }
}

